//列表搜索参数
export type searchType = {
  keyword:string,
  page:number,
  pageSize:number,
  isStar:boolean,
  isPublished:boolean,
  isDeleted:boolean,
}


//登录类型
export type loginType = {
  username:string,
  password:string,
}

//注册类型
export type registerType = loginType & {
  nickname:string,
}

//问卷类型
export type questionType = {
  id?:string,
  title?:string,
  isPublished?:boolean,
  isStar?:boolean,
  answerCount?:number,
  createdAt?:string,
}

//计数器仓库类型
export type counterStoreType = {
  copiedComponent: questionComponentType | null;
  selectedId: string;
  setSelectedId: (id: string) => void;
  setCopiedComponent: (component: questionComponentType) => void;
}
//用户类型
export type userInfoType = {
   username:string,
   nickname:string,
} 
//用户仓库类型
export type userStoreType = {
  info: userInfoType | null;
  setInfo: (info: userInfoType) => void;
  token:string,
  setToken: (token: string) => void;
}

export type QuestionInputPropsType = {
   title?:string
   placeholder?:string
}


export type QuestionTitlePropsType = {
   text?: string
   level?:1|2|3                    
   isCenter?: boolean
}

export type QuestionParagraphPropsType = {
   text?: string,
   isCenter?: boolean
}

export type QuestionInfoPropsType = {
   title?: string,
   desc?: string,
}

export type QuestionTextareaPropsType = {
  title?: string,
  placeholder?: string,
}


export type OptionType ={
  value:string
  label:string
  checked?:boolean
}

export type QuestionRadioPropsType = {
   title?: string,
   isVertical?: boolean, 
   options?: OptionType[],
   value?: string
}

export type QuestionCheckboxPropsType = {
   title?: string,
   isVertical?: boolean, 
   options?: OptionType[],
}


//问卷组件类型
export type questionComponentType = {
  fe_id:string
  type:string
  title:string
  isHidden:boolean
  isLocked:boolean
  props:QuestionCheckboxPropsType & QuestionInputPropsType & QuestionTitlePropsType & QuestionParagraphPropsType & QuestionInfoPropsType & QuestionRadioPropsType ;
}



//问卷组件仓库类型
export type questionComponentStoreType = {
  componentList: questionComponentType[],
  setComponentList: (componentList: questionComponentType[]) => void,
  addComponent: (component: questionComponentType,selectedId:string) => void,
  updateComponent: (component: questionComponentType) => void,
  deleteComponent: (componentId: string) => void,
  hiddenComponent: (componentId: string) => void,
  lockComponent: (componentId: string) => void,
  moveComponent: (oldId: number, newIndex: number) => void,
  updateTitle: (componentId: string, title: string) => void,
}

export type pageInfoType = {
  title?:string
  desc?:string
  js?:string
  css?:string
  isPublished?:boolean
}

//页面信息仓库类型
export type pageInfoStoreType = {
  pageInfo:pageInfoType
  setPageInfo: (pageInfo: pageInfoType) => void
}

//问卷类型
export type questionParamsType =questionType & pageInfoType & {
  componentList:questionComponentType[]
}


//主仓库类型
export type storeType = pageInfoStoreType & counterStoreType & userStoreType;





//prop类型
export type propsType = {
  num?: number;                 //num可以是number类型
  children?: React.ReactNode;  //children可以是任何ReactNode类型
  onEvent?: () => void;        // onClick可以是函数类型
}

export type resultDataType ={
   
  [key:string] : any
}

export type resultType = {
  errno:number,
  data?:resultDataType,
  msg?:string,
}